#include "pointcloud_tools.h"
// #include "point_display.h"
#include <iostream>
#include "point_common.h"

using namespace  pointcloud_tools;
int main(int argc, char** argv) {
    Pointcloud_utils ptu;
    assert(ptu.Model_DDR_alloc("DDR_32MB.bin"));
    // Layer Config
    ptu.layer_config.cfg_inch_loop_num = 3;
    ptu.DDR_BASE_ADDR = 0x95000000;
    ptu.layer_config.BASE_WT_ADDR = ptu.DDR_BASE_ADDR + 0x000100000; // 0x650000400; 
    ptu.layer_config.cfg_shift_num = 9;
    // Block Config 
    BlockConfig bcfg; 
    bcfg.cfg_cam_valid_num = 10;
    bcfg.cfg_total_point_num = 10;
    bcfg.BASE_PT_ADDR = ptu.DDR_BASE_ADDR;
    bcfg.BASE_IN_ADDR = ptu.DDR_BASE_ADDR + 0x400;
    bcfg.BASE_RS_ADDR = ptu.DDR_BASE_ADDR + 0x000200000;

    ptu.Model_RandomDataGenerator(); // Generate spilt weight.bin input_block_xxxxxx.bin point_block_xxxxx.bin
    size_t dlen = readBinToVec(bcfg.pt_data, "./RunsFiles/point_block_000000.bin");
    assert(dlen > 0);
    dlen = readBinToVec(bcfg.in_data, "./RunsFiles/input_block_000000.bin");
    assert(dlen > 0);
    dlen = readBinToVec(ptu.layer_config.wt_data, "./RunsFiles/weight.bin");
    assert(dlen > 0);
    ptu.block_config.push_back(bcfg);
    

    //Instruction Generator
    ptu.wt_init();
    ptu.compute_init();
    //Simulation Model
    ptu.ddrSize = 8 * 1024 * 1024 * sizeof(int); //32MB
    
    
    ptu.run(); // Run the model, which will read weight.bin input_block_xxxxxx.bin point_block_xxxxx.bin and write result to DDR
    // ptu.Model_DDR_init(); // Init DDR according to BASE_xx_ADDR from generated bin
    // ptu.Model_SubConvCompute(); // Compute SubConv according to DDR FILE and BASE_xx_ADDR
    assert(ptu.Model_DDR_close()); // Release DDR File
}

  



